package cn.aitrox.ry.service.anno.dao.impl;

import cn.aitrox.ry.common.dao.MapperSqlCallback;
import cn.aitrox.ry.common.dao.impl.BaseDaoImpl;
import cn.aitrox.ry.service.anno.dao.AnnoLesionResultDetailDao;
import cn.aitrox.ry.service.anno.entity.AnnoLesionResultDetailEntity;
import cn.aitrox.ry.service.anno.mapper.AnnoLesionResultDetailMapper;
import cn.aitrox.ry.util.ArrayUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class AnnoLesionResultDetailDaoImpl extends BaseDaoImpl<AnnoLesionResultDetailEntity> implements AnnoLesionResultDetailDao {

    @Autowired
    private AnnoLesionResultDetailMapper mapper;

    @Override
    public void batchSave(List<AnnoLesionResultDetailEntity> detailEntityList) {
        super.batchInsert(detailEntityList, 500, new MapperSqlCallback<AnnoLesionResultDetailEntity>() {
            @Override
            public void batchInsert(List<AnnoLesionResultDetailEntity> objList) {
                mapper.batchInsert(objList);
            }
        });
    }

    @Override
    public void deleteByAlrIdGroupId(Integer alrId, String groupId) {
        mapper.deleteByAlrIdGroupId(alrId, groupId);
    }

    @Override
    public List<AnnoLesionResultDetailEntity> findByAlrIds(List<Integer> alrIdList) {
        if(ArrayUtil.isEmpty(alrIdList)) {
            return new ArrayList<>();
        }
        return mapper.findByAlrIds(alrIdList);
    }
}
